package com.shanghaionstar.activity.webview.handler;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by Rengui Lu on 2017/3/3.
 */
public class WebDataEntity implements Parcelable {
    private String linkUrl;
    private String topTitle;
    private boolean canGoBack;
    private String clzName;
    private String fromPage;
    public int what = IWebType.TYPE_NORMAL;

    public String getFromPage() {
        return fromPage;
    }

    public void setFromPage(String fromPage) {
        this.fromPage = fromPage;
    }

    public int getWhat() {
        return what;
    }

    public void setWhat(int what) {
        this.what = what;
    }


    public String getClzName() {
        return clzName;
    }

    public void setClzName(String clzName) {
        this.clzName = clzName;
    }

    public boolean isCanGoBack() {
        return canGoBack;
    }

    public void setCanGoBack(boolean canGoBack) {
        this.canGoBack = canGoBack;
    }

    public WebDataEntity() {

    }

    public String getLinkUrl() {
        return linkUrl;
    }

    public void setLinkUrl(String linkUrl) {
        this.linkUrl = linkUrl;
    }

    public String getTopTitle() {
        return topTitle;
    }

    public void setTopTitle(String topTitle) {
        this.topTitle = topTitle;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeString(linkUrl);
        out.writeString(topTitle);
        out.writeByte((byte) (canGoBack ? 1 : 0));
        out.writeString(clzName);
        out.writeString(fromPage);
        out.writeInt(what);
    }

    public static final Parcelable.Creator<WebDataEntity> CREATOR = new Creator<WebDataEntity>() {

        @Override
        public WebDataEntity[] newArray(int size) {
            return new WebDataEntity[size];
        }

        @Override
        public WebDataEntity createFromParcel(Parcel in) {
            return new WebDataEntity(in);
        }
    };

    public WebDataEntity(Parcel in) {
        //如果元素数据是list类型的时候需要： lits = new ArrayList<?> in.readList(list);
        //否则会出现空指针异常.并且读出和写入的数据类型必须相同.如果不想对部分关键字进行序列化,可以使用transient关键字来修饰以及static修饰.
        linkUrl = in.readString();
        topTitle = in.readString();
        canGoBack = in.readByte() != 0;
        clzName = in.readString();
        fromPage = in.readString();
        what = in.readInt();
    }

}
